package com.hzlx.finishedGoods.feign.fallback;

import com.hzlx.ResultDto;
import com.hzlx.WorkOrderDto;
import com.hzlx.finishedGoods.feign.WorkOrderService;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.Collections;
import java.util.List;

@Component
public class WorkOrderServiceFallbackFactory implements FallbackFactory<WorkOrderService> {
    @Override
    public WorkOrderService create(Throwable cause) {
        return new WorkOrderService() {
            @Override
            public List<WorkOrderDto> getInfoDto(Long productId) {
                System.err.println("WorkOrderService 调用失败，触发降级逻辑，productId=" + productId);
                cause.printStackTrace();
                return Collections.emptyList();
            }

            @Override
            public void editByMaterial(WorkOrderDto workOrderDto) {
                System.err.println("WorkOrderService 更新工单失败，触发降级逻辑，workOrderDto=" + workOrderDto);
                cause.printStackTrace();
            }
        };
    }
}
